<script type="text/javascript">
function updateMessage(id, change)
  {
	   // alert("updateMessage(id := " + id + ", change := " + change + ")");
	    
     var content = "<c:out escapeXml='false' value='${message.contentStringEscaped}' />";
     var newContent = "";
     var contentArray = content.split(" ");

     var functionSelector = document.getElementById("dialogueActArray" + id + ".function"); 
     var startSelector = document.getElementById("dialogueActArray" + id + ".startIndex"); 
     var endSelector = document.getElementById("dialogueActArray" + id + ".endIndex"); 
      
     var startValue = parseInt(startSelector.value); 
     var endValue = parseInt(endSelector.value);

     var functionText= functionSelector.options[(functionSelector.selectedIndex)].text; 

     // alert(functionText + " is selected!");
     
      // alert('startValue: ' + startValue + ' endValue: ' + endValue);
     if (change == "start" && startValue > endValue) {
        // alert ("startValue > endValue!");
         endSelector.value  = endValue = startValue;
     }

     if (change == "end" && startValue > endValue) {
        // alert ("startValue > endValue!");
       startSelector.value  = startValue = endValue;
     } 

     for (var i = 0; i < contentArray.length; i++) 
     {
       if (i == startValue)
           newContent += "<font class=\"active_" + functionText.substr(0,4).toLowerCase() + "\">";

       newContent += " " + contentArray[i];

       if (i == endValue)
           newContent += "</font>";
	    }
      //alert('Setting: ' + newContent)
      document.getElementById("messageContent").innerHTML = newContent;
     
  }
  </script>